var Web3 = require("web3");

// 创建web3对象
var web3 = new Web3();
// 连接到以太坊节点
web3.setProvider(new Web3.providers.HttpProvider("http://192.168.1.89:8545"));

// 合约ABI
var abi = [{
    "constant": true,
    "inputs": [],
    "name": "name",
    "outputs": [{
        "name": "",
        "type": "string"
    }],
    "payable": false,
    "type": "function"
},
    {
        "constant": true,
        "inputs": [],
        "name": "decimals",
        "outputs": [{
            "name": "",
            "type": "uint8"
        }],
        "payable": false,
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [{
            "name": "_owner",
            "type": "address"
        }],
        "name": "balanceOf",
        "outputs": [{
            "name": "balance",
            "type": "uint256"
        }],
        "payable": false,
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "symbol",
        "outputs": [{
            "name": "",
            "type": "string"
        }],
        "payable": false,
        "type": "function"
    }
];// 合约地址


var address = "0x7dda0962c0644a3f0089edd702a454d507294de6";
// 通过ABI和地址获取已部署的合约对象
 var contract = web3.eth.contract(abi).at(address);
// contract.transfer("0x69eccf22bc78eb443e324869b8ec2f386baeb38d",10);
console.log(contract.balanceOf("0x471912d13bbe0a91aaa553af4af048885943bd61").toNumber())
console.log(contract.balanceOf("0x69eccf22bc78eb443e324869b8ec2f386baeb38d").toNumber())
console.log(web3.eth.getBalance("0x471912d13bbe0a91aaa553af4af048885943bd61").toNumber());

// var account_one = web3.eth.coinbase;
// var account_one_balance = contract.getBalance.call(account_one);
// console.log("account one balance: ", account_one_balance.toNumber());

